package cn.quevo.cube.provide.data.enums;


import cn.quevo.cube.provide.data.validate.AbstractColumnDataValidate;
import cn.quevo.cube.provide.data.validate.impl.*;

/**
 * 字段数据验证枚举
 *
 * @author July july_sky@foxmail.com
 * @version 1.0
 * @date 2018/4/26 下午1:44
 * @Copyright ©2015-2035 湘豫(北京)科技有限公司. All Rights Reserved.
 */
public enum DataValidate {
    TEXT(TextValidate.class),
    LONG_TEXT(TextValidate.class),
    BIGINT(BigintValidate.class),
    NUMERIC(NumericValidate.class),
    DATE(DateValidate.class),
    TIME(TimeValidate.class),
    ENUM(EnumValidate.class),
    RADIO(RadioValidate.class),
    CHECKBOX(CheckBoxValidate.class),

    EMAIL(EmailValidate.class),
    WEB_SITE(WebSiteValidate.class),
    MOBILE(MobileValidate.class),
    PHONE(PhoneValidate.class),
    CARD(CardValidate.class);

    private Class validateClass;

    DataValidate(Class validateClass) {
        this.validateClass = validateClass;

    }

    public AbstractColumnDataValidate getValidateClass() {
        try {
            return (AbstractColumnDataValidate) this.validateClass.newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return null;
    }
}
